package com.it.plic;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author げっしょく
 * @date 2021/8/8
 */
public class Demo6_1 {

    public static void main(String[] args) throws IOException {
        //创建一个服务端，监听10000窗口
        ServerSocket s = new ServerSocket(10000);
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("Day16\\info.txt"));
        //BufferedOutputStream  = new BufferedOutputStream(new FileOutputStream("Day16\\info.txt"));
        Socket accept = s.accept();
        InputStream is = accept.getInputStream();
        int a;
        while ((a = is.read()) != -1){
            bos.write(a);
        }
        accept.shutdownInput();

        BufferedOutputStream bs = new BufferedOutputStream(accept.getOutputStream());
        bs.write("收到了，over".getBytes());
        bs.close();
        bos.close();
        is.close();
        s.close();
    }
}
